package com.droolsdemo.rule;

import org.kie.api.KieBase;
import org.kie.api.io.ResourceType;
import org.kie.internal.utils.KieHelper;

public class NewKieBase {


    /*
    *   将业务规则写到数据库中
    *   1.rule 就是动态传入的规则
    *
    * */
    public static KieBase ruleKieBase(String rule) {

        KieHelper kieHelper = new KieHelper();
        KieBase kieBase = null;
        try {
            kieHelper.addContent(rule, ResourceType.DRL);
            kieBase = kieHelper.build();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return kieBase;
    }
}
